#import <Foundation/Foundation.h>
#import <sqlite3.h>
#import "person.h"

@interface  DatabaseInteraction : NSObject {
	sqlite3 *database;
	NSString* databasePath;
}

//if the database is not in default directory, create one
- (void)checkAndCreateDatabase;

//Update database using an array of Directory or Personal information
- (void)saveDirectoryContactsToDatabase:(NSArray*)firstNameList lastName:(NSArray*)lastNameList UNID:(NSArray*)UNIDList;
- (void)savePersonalContactsToDatabase:(NSArray*)list;

//Update database with detail information, so we don't have to get it from web when needed next time
- (void)updatePersonalWithPerson:(Person *)personInfo;
- (void)updateDirectoryUseUNID:(NSString*)UNID withEmail:(NSString *)email phone:(NSString*)phoneNumber;

//Tasks that should save to database, which can be restored when back online
- (void)saveOperationToDatabase:(NSURL *)URL type:(int)type data:(NSData*)data description:(NSString*)description;
- (NSArray*)getOperationsFromDatabase ;
- (void)deleteOperationInDatabase:(NSURL *)URL;
- (void)resetDirectoryDatabase;

@end

/*
CREATE TABLE operation ('URL' CHAR(256) PRIMARY KEY, 'type' CHAR(16), 'data' CHAR(256), 'description' CHAR(128))
 
CREATE TABLE personal ('UNID' char(48) PRIMARY KEY, 'prefix' CHAR(16), 'firstName' CHAR(16),  'middleName' char(16),
'lastName' char(16), 'suffix' char(16),'jobTitle' char(32), 'department' char(32), 'organization' char(48), 
'email' char(48), 'street' char(32), 'city' char(32), 'state' char(32), 'zip' char(16), 'country' char(32),
'mobile' char(32), 'workPhone' char(32), 'workFax' char(32), 'workPager' char(32), 'homeFax' char(32), 'updated' char(32));
 
CREATE TABLE directory ('UNID' CHAR(48) PRIMARY KEY, 'firstName' CHAR(32), 'lastName' CHAR(32), 'email' CHAR(48),
'phoneNumber' CHAR(32), 'updated' char(32))
*/